package com.mccken.common;

import com.mccken.springframework.beans.BeansException;
import com.mccken.springframework.beans.UserService;
import com.mccken.springframework.beans.factory.config.BeanPostProcessor;

/**
 * @program: mccken-collect
 * @description:
 * @author: mccken
 * @create: 2022-12-28 00:37
 **/
public class MyBeanPostProcessor implements BeanPostProcessor {
	@Override
	public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
		if ("userService".equals(beanName)) {
			UserService userService = (UserService) bean;
			userService.setLocation("改为：北京");
		}
		return bean;
	}

	@Override
	public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
		return bean;
	}
}
